package vista;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;                                                   
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.SwingUtilities;
import controlador.ControladorVentanaReubicar;


/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class VentanaReubicar extends javax.swing.JFrame {



	private JLabel lblCodLote;
	private JTextField txtCodLote;
	private JTextField txtContenedor;
	private JLabel lblContenedor;
	private JButton btnFinalizar;
	private JTextField txtDeposito;
	private JLabel jLabel1;
	private JButton btnCancelarUb;
	private JButton btnUbicar;
	private JComboBox cmbNum;
	private JComboBox cmbDeposito;
	private JPanel jPanelRadioBtn;
	private JLabel lblDeposito;
	private JPanel panUbicar;
	private JButton btnSalir;
	private JButton btnCancelar;
	private JButton btnReubicar;
	private JButton btnBuscarLote;
	private JLabel lblNombPro;
	private JTextField txtNombPro;
	private JLabel lblCantLote;
	private JTextField txtCantLote;
	private JRadioButton btnPaleta;
	private JRadioButton btnEstante;

	/**
	 * Auto-generated main method to display this JFrame
	 */



	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VentanaReubicar inst = new VentanaReubicar();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}

	public VentanaReubicar() {
		super();
		initGUI();
	}



	public void agregarListener(ControladorVentanaReubicar accion){


		btnUbicar.addActionListener(accion);
		btnCancelarUb.addActionListener(accion);
		btnReubicar.addActionListener(accion);
		btnBuscarLote.addActionListener(accion);
		btnFinalizar.addActionListener(accion);
		btnCancelar.addActionListener(accion);
		btnSalir.addActionListener(accion);
		btnEstante.addItemListener(accion);
		btnPaleta.addItemListener(accion);



	}



	public void setCodLote(String cod){
		txtCodLote.setText(cod);
	}
	
	public void setDeposito(String dep){
		txtDeposito.setText(dep);
	}
	
	public void setContenedor(String cont){
		txtContenedor.setText(cont);
	}

	

	public void setNombPro(String nomp){
		txtNombPro.setText(nomp);
	}

	public String getNombPro(){
		return txtNombPro.getText();
	}

	public void setCantLote(int can){
		txtCantLote.setText(String.valueOf(can));
	}

	public int getCantLote(){
		return Integer.valueOf(txtCantLote.getText());
	}
	
	
	public String getCodigoLote(){
		return txtCodLote.getText();
	}


      //Metodo para limpiar los campos
	public void limpiarCampos(){
		txtCodLote.setText("");
		txtNombPro.setText("");
		txtCantLote.setText("");
		txtContenedor.setText("");
		txtDeposito.setText("");

	}
	
    public void inhabilitar(){

	}
    
    public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}

	public JRadioButton getRbtPaleta() {
		return btnPaleta;
	}

	public JRadioButton getRbtEstante() {
		return btnEstante;
	}



	/*public int getCmbDeposito(){
		return Integer.parseInt((String)cmbDeposito.getSelectedItem());
	}*/
	
	public String getCmbDeposito(){
		return cmbDeposito.getSelectedItem().toString();
	}
	
	public String getCmbNum(){
		return cmbNum.getSelectedItem().toString();
	}
	
	
	public String getOpcionSeleccionada() {
		if (btnPaleta.isSelected())
			return btnPaleta.getText();
		else if (btnEstante.isSelected())
		   return btnEstante.getText();
		else
			return "";		
	}
	

	/************************************************/

	public void llenarComboPaleta(int numero){
		cmbNum.removeAllItems();
		cmbNum.addItem("Seleccione una opcion");
		for(int i = 1; i <= numero; i++)
			cmbNum.addItem(i);
	} 

	public void llenarComboEstante(int numero){
		cmbNum.removeAllItems();
		cmbNum.addItem("Seleccione una opcion");
		for (int i = 1; i <= numero; i++) {
			cmbNum.addItem(i);
		}
	}


	public void setDepositosComboBox(ArrayList<String> nombre){
		cmbDeposito.removeAll();
		cmbDeposito.addItem("Seleccione una opcion");
		for(int i = 0; i < nombre.size();i++)
			cmbDeposito.addItem(nombre.get(i));
	}

	/************************************************/

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Reubicacion");
			{
				lblCodLote = new JLabel();
				getContentPane().add(lblCodLote);
				lblCodLote.setText("Codigo Lote:");
				lblCodLote.setBounds(29, 24, 69, 15);
			}
			{
				txtCodLote = new JTextField();
				getContentPane().add(txtCodLote);
				txtCodLote.setBounds(98, 21, 91, 22);
			}
			{
				btnBuscarLote = new JButton();
				getContentPane().add(btnBuscarLote);
				btnBuscarLote.setText("Buscar");
				btnBuscarLote.setBounds(212, 21, 81, 22);
			}
			{
				lblNombPro = new JLabel();
				getContentPane().add(lblNombPro);
				lblNombPro.setText("Producto:");
				lblNombPro.setBounds(29, 58, 61, 15);
			}
			{
				txtNombPro = new JTextField();
				getContentPane().add(txtNombPro);
				txtNombPro.setBounds(98, 57, 91, 17);
				txtNombPro.setEnabled(false);
				txtNombPro.setFont(new java.awt.Font("Calibri",1,13));
			}
			{
				lblCantLote = new JLabel();
				getContentPane().add(lblCantLote);
				lblCantLote.setText("Cantidad:");
				lblCantLote.setBounds(29, 121, 60, 15);
			}
			{
				txtCantLote = new JTextField();
				getContentPane().add(txtCantLote);
				txtCantLote.setBounds(97, 120, 34, 18);
				txtCantLote.setEnabled(false);
				txtCantLote.setFont(new java.awt.Font("Calibri",1,13));
			}
			{
				btnReubicar = new JButton();
				getContentPane().add(btnReubicar);
				btnReubicar.setText("Reubicar");
				btnReubicar.setBounds(24, 150, 94, 22);
			}
			{
				btnFinalizar = new JButton();
				getContentPane().add(btnFinalizar);
				btnFinalizar.setText("Finalizar");
				btnFinalizar.setBounds(24, 339, 99, 22);
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(143, 339, 87, 22);
			}
			{
				btnSalir = new JButton();
				getContentPane().add(btnSalir);
				btnSalir.setText("Salir");
				btnSalir.setBounds(241, 339, 109, 22);
			}
			{
				panUbicar = new JPanel();
				getContentPane().add(panUbicar);
				panUbicar.setBounds(18, 181, 340, 136);
				panUbicar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				panUbicar.setLayout(null);
				{
					lblDeposito = new JLabel();
					panUbicar.add(lblDeposito);
					lblDeposito.setText("Deposito:");
					lblDeposito.setBounds(85, 17, 60, 15);
				}
				{
					ComboBoxModel cmbProductoModel = 
							new DefaultComboBoxModel(
									new String[] {  });
					cmbDeposito = new JComboBox();
					panUbicar.add(cmbDeposito);
					cmbDeposito.setModel(cmbProductoModel);
					cmbDeposito.setBounds(197, 13, 125, 22);
				}
				{
					ComboBoxModel cmbNumModel = 
							new DefaultComboBoxModel(
									new String[] {  });
					cmbNum = new JComboBox();
					panUbicar.add(cmbNum);
					cmbNum.setModel(cmbNumModel);
					cmbNum.setBounds(197, 55, 126, 22);
				}
				{
					btnUbicar = new JButton();
					panUbicar.add(btnUbicar);
					btnUbicar.setText("Ubicar");
					btnUbicar.setBounds(26, 101, 135, 22);
				}
				{
					btnCancelarUb = new JButton();
					panUbicar.add(btnCancelarUb);
					btnCancelarUb.setText("Cancelar Ubicacion");
					btnCancelarUb.setBounds(190, 101, 139, 22);
				}
				{
					ButtonGroup rBtnGroup = new ButtonGroup();

					btnPaleta = new JRadioButton("Paleta");
					btnPaleta.setActionCommand("Paleta");
					btnPaleta.setSelected(true);

					btnEstante = new JRadioButton("Estante");
					btnEstante.setActionCommand("Estante");

					rBtnGroup.add(btnPaleta);
					btnPaleta.setBounds(38, 71, 53, 21);
					rBtnGroup.add(btnEstante);
				}

			}
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Deposito:");
				jLabel1.setBounds(29, 93, 52, 17);
			}
			{
				txtDeposito = new JTextField();
				getContentPane().add(getTxtDeposito());
				txtDeposito.setBounds(97, 93, 34, 18);
				txtDeposito.setEnabled(false);
				txtDeposito.setFont(new java.awt.Font("Calibri",1,13));
			}
			{
				lblContenedor = new JLabel();
				getContentPane().add(lblContenedor);
				lblContenedor.setBounds(141, 93, 68, 17);
				lblContenedor.setText("Contenedor:");
			}
			{
				txtContenedor = new JTextField();
				getContentPane().add(txtContenedor);
				txtContenedor.setBounds(212, 93, 77, 18);
				txtContenedor.setEnabled(false);
				txtContenedor.setFont(new java.awt.Font("Calibri",1,13));
			}
			{
				jPanelRadioBtn = new JPanel();
				panUbicar.add(jPanelRadioBtn);
				GroupLayout jPanelRadioBtnLayout = new GroupLayout((JComponent)jPanelRadioBtn);
				jPanelRadioBtn.setLayout(jPanelRadioBtnLayout);
				jPanelRadioBtn.setBounds(36, 38, 109, 51);
				jPanelRadioBtn.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				jPanelRadioBtnLayout.setHorizontalGroup(jPanelRadioBtnLayout.createSequentialGroup()
					.addGap(7)
					.addGroup(jPanelRadioBtnLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelRadioBtnLayout.createSequentialGroup()
					        .addComponent(btnPaleta, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
					    .addGroup(jPanelRadioBtnLayout.createSequentialGroup()
					        .addComponent(btnEstante, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 0, Short.MAX_VALUE)))
					.addContainerGap());
				jPanelRadioBtnLayout.setVerticalGroup(jPanelRadioBtnLayout.createSequentialGroup()
					.addComponent(btnPaleta, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addComponent(btnEstante, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
			}
			pack();
			this.setSize(387, 411);
		} catch (Exception e) {
			//add your error handling code here
			e.printStackTrace();
		}
	}
	
	public JTextField getTxtDeposito() {
		return txtDeposito;
	}

}
